﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>移交信息管理</title>
    <#include "../common/link.ftl">

    <script>
        $(function () {

            //新增或编辑按钮的点击事件
            $('.btn-input').click(function () {
                //先清除之前模态框的数据
                $('#transferModal input').val('')
                //给编辑显示的模态框回显数据
                //获取事件源绑定的数据 用data方法可以很方便的获取data-* 开头的属性的数据
                var json = $(this).data("json");//json是当前客户对象
                if (json) {
                    $("#transferForm input[name=id]").val(json.id);
                    $("#transferForm textarea[name=reason]").val(json.reason);
                    $("#transferForm input[name='customer.name']").val(json.customerName);
                    $("#transferForm input[name='customer.id']").val(json.customerId);
                    $("#transferForm input[name='oldseller.name']").val(json.oldsellerName);
                    $("#transferForm input[name='oldseller.id']").val(json.oldsellerId);
                    $("#transferForm select[name='newseller.id']").val(json.newsellerId);
                }
                //打开模态框
                $('#transferModal').modal('show');

            })
            //保存操作
            $('.transferSubmit').click(function () {
                //使用jquery-form插件来提交异步表单(有表单时会使用该插件,写的代码比较少)
                $("#transferForm").ajaxSubmit(function (data) {
                    handlerMessage(data)
                })
            })

            //-------------------------------

            //时间插件
            $('.datepicker').datepicker({
                language: 'zh-CN',
                autoclose: true,
                todayHighlight: true, // 今天时间高亮
                format: 'yyyy-mm-dd',
                endDate:new Date() // 今天之后的日期都不可以选择
            });

            //-------------------------------


        })
    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="customerTransfer"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>移交信息管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/customerTransfer/list.do" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">

                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                               placeholder="请输入客户姓名">
                    </div>

                    <div class="form-group">
                        <label for="dept">新销售人员:</label>
                        <select name="newSellerId" id="newsellerqo" class="form-control">
                                <option value="-1">全部</option>
                                <#list sellers as e>
                                    <option value="${e.id}">${e.name}</option>
                                </#list>
                        </select>
                        <script>
                            $("#newsellerqo option[value='${(qo.newSellerId)!}']").prop("selected", true);
                        </script>
                    </div>

                    <button id="btn_query" class="btn btn-primary">
                        <span class="glyphicon glyphicon-search"></span>
                        查询
                    </button>
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户姓名</th>
                            <th>操作人</th>
                            <th>操作时间</th>
                            <th>旧销售人</th>
                            <th>新销售人</th>
                            <th>移交原因</th>
                            <th>操作</th>
                        </tr>
                            <#list result.list as c>
                                <tr>
                                    <td>${c_index+1}</td>
                                    <td>${(c.customer.name)!}</td>
                                    <td>${(c.operator.name)!}</td>
                                    <td>${(c.operateTime?string("yyyy-MM-dd"))!}</td>
                                    <td>${(c.oldseller.name)!}</td>
                                    <td>${(c.newseller.name)!}</td>
                                    <td>${(c.reason)!}</td>
                                    <td>
                                        <a href="#"
                                           class="btn btn-info btn-xs btn-input" data-json='${c.json}'>
                                            <span class="glyphicon glyphicon-pencil"></span> 编辑
                                        </a>
                                    </td>
                                </tr>
                            </#list>
                    </table>
                    <!--分页-->
                <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<#--移交模态框-->
<div id="transferModal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新增/编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTransfer/saveOrUpdate.do" method="post" id="transferForm" style="margin: -3px 118px">
                    <input type="hidden" name="id" id="customerTransferId"/>
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">客户姓名：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="customer.name"   readonly >
                            <input type="hidden" class="form-control"  name="customer.id"  >
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">旧营销人员：</label>
                        <div class="col-sm-8">
                            <input type="text" class="form-control"  name="oldseller.name" readonly >
                            <input type="hidden" class="form-control"    name="oldseller.id"  >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">新营销人员：</label>
                        <div class="col-sm-8">
                            <select name="newseller.id" id="newseller" class="form-control">
                                <#list sellers as e>
                                    <option value="${e.id}">${e.name}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">移交原因：</label>
                        <div class="col-sm-8">
                            <textarea type="text" class="form-control" id="reason" name="reason" cols="10" ></textarea>
                        </div>
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary transferSubmit" >保存</button>
            </div>
        </div>
    </div>
</div>



</body>
</html>
